package com.hqyj.emb.system.controller;

import com.hqyj.emb.system.model.User2;
import frame.controller.BaseController2;
import frame.model.PageBean;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user2Controller.do")
public class User2Controller extends BaseController2 {

    public int getPC(HttpServletRequest req, HttpServletResponse resp) {

        String value = req.getParameter("pc");
        if (value == null || value.trim().isEmpty()) {
            return 1;
        }
        return Integer.parseInt(value);

    }

    /**
     * @Description:f分頁
     * @return: java.lang.String
     * @Author: zlf
     * @Date: 2020/8/6 10:16
     */
    public String listPage(HttpServletRequest req, HttpServletResponse resp) {

        // 1、接受数据
        System.out.println("------------listPage()---");
        // a、 获取页面传递的pc:当前页码（page code）
        int pc = getPC(req, resp);
        // b、给定ps的值:每页记录数（page size）
        int ps = 6;

        // 3、调用业务
        PageBean<User2> pageBean = user2Service.queryAllPage(pc, ps);
        req.setAttribute("pb", pageBean);

        //2.跳转页面
        return "view/system/user2/user2List.jsp";
    }
}
